<?php

namespace App\Clients\JinShouFu;

use GuzzleHttp\Exception\GuzzleException;
use phpQuery;
class StoreList extends JinShouFuClient
{
    protected $isJson = false;

    public function handleData(): void
    {
        $html = phpQuery::newDocument($this->contents);
        $storeList = [];
        $html->find("#store_select option")->each(function($item)use(&$storeList){
            $ele = pq($item);
            if(empty($ele->val())) return;
            $storeList[] = [
                "storeId"=>$ele->val(),
                "storeName"=>$ele->text()
            ];
        });
        $this->contents = $storeList;
    }


    /**
     * @throws GuzzleException
     */
    public function execute($queryData): StoreList
    {
        return $this->get("https://www.jsfpay.com/store/storeList.do",$queryData);
    }
}
